Exemplo n.º 1
0
        private int InsertStockInItem()
        {
            grvReturn.EndEdit();
            ArrayList arr = new ArrayList();
            ArrayList SiArr = new ArrayList();
            bool ret = true;
            bool rr = true;
            double cnt = 0;
            cnt = grvReturn.Rows.Count;
            StockInData sd = new StockInData();
            sd.GRANDTOT = Convert.ToDouble(txtGrandTot.Text.Trim());
            sd.LOID = Convert.ToDouble(_LOID.ToString());
            sd.REASON = txtReason.Text.Trim();
            sd.REMARK = txtRemark.Text.Trim();
            SiArr.Add(sd);
            if (_FLAG == "ADD")
            {
                for (int i = 0; i < cnt; i++)
                {

                    DataGridViewTextBoxCell QTY = (DataGridViewTextBoxCell)grvReturn.Rows[i].Cells["QTY"];
                    DataGridViewTextBoxCell STOCKIN = (DataGridViewTextBoxCell)grvReturn.Rows[i].Cells["SILOID"];
                    DataGridViewTextBoxCell PRODUCT = (DataGridViewTextBoxCell)grvReturn.Rows[i].Cells["PDLOID"];
                    DataGridViewTextBoxCell REFLOID = (DataGridViewTextBoxCell)grvReturn.Rows[i].Cells["RQILOID"];
                    DataGridViewTextBoxCell PRICE = (DataGridViewTextBoxCell)grvReturn.Rows[i].Cells["PRICE"];
                    DataGridViewTextBoxCell ULOID = (DataGridViewTextBoxCell)grvReturn.Rows[i].Cells["ULOID"];

                    StockInItemData dr = new StockInItemData();
                    dr.QTY = Convert.ToDouble(QTY.Value.ToString());
                    dr.STOCKIN = Convert.ToDouble(STOCKIN.Value.ToString());
                    dr.PRODUCT = Convert.ToDouble(PRODUCT.Value.ToString());
                    dr.REFLOID = Convert.ToDouble(REFLOID.Value.ToString());
                    dr.PRICE = Convert.ToDouble(PRICE.Value.ToString());
                    dr.UNIT = Convert.ToDouble(ULOID.Value.ToString());
                    arr.Add(dr);
                }

                ReturnSearchFlow csFlow = new ReturnSearchFlow();
                ret = csFlow.InsertStockInitem(Appz.CurrentUserData.UserID, arr);
                if (ret == true)
                {
                    rr = csFlow.UpdateStockIn_GrandTot(Appz.CurrentUserData.UserID, SiArr);
                    setStatusRequisition("0", "VO");
                    return 1;
                }
                else
                {
                    Appz.OpenWarningDialog(csFlow.ErrorMessage);
                    return 0;
                }
            }
            else
            {
                if (txtSiiStatus.Text.Trim() == "AP")
                {
                    Appz.OpenWarningDialog("ÃÒ¡ÒùÕé¶Ù¡Â×¹ÂѹáÅéÇ");
                    return 0;
                }
                else
                {
                    //¡Ã³Õ update ¨Ó¹Ç¹ÃѺ¤×¹
                //    for (int i = 0; i < cnt; i++)
                //    {
                //        DataGridViewTextBoxCell SIILOID = (DataGridViewTextBoxCell)grvReturn.Rows[i].Cells["SIILOID"];
                //        DataGridViewTextBoxCell QTY = (DataGridViewTextBoxCell)grvReturn.Rows[i].Cells["QTY"];
                //        StockInItemData dr = new StockInItemData();
                //        dr.LOID = Convert.ToDouble(SIILOID.Value.ToString());
                //        dr.QTY = Convert.ToDouble(QTY.Value.ToString());
                //        arr.Add(dr);
                //    }

                //    ReturnSearchFlow csFlow = new ReturnSearchFlow();


                //    ret = csFlow.UpdateTemptable(Appz.CurrentUserData.UserID, arr);
                //    if (ret == true)
                //    {
                //        rr = csFlow.UpdateStockIn_GrandTot(Appz.CurrentUserData.UserID, SiArr);
                //        return 2;
                //    }
                //    else
                //    {
                //        Appz.OpenWarningDialog(csFlow.ErrorMessage);
                        return 0;
                    }
                }
            }