Esempio n. 1
0
        private void btn_add_List_Click(object sender, System.EventArgs e)
        {
            if (!validasiTextBoxpart())
            {
                return;
            }
            if (StatusEdit)
            {
                layerTmpBom.UpdatetTemp(PrtGUID, qty,Discount);
                clsWin.SuccessMessage("record Update", "Success");

                //Btn_refresh.PerformClick();
                getListData();
            }
            else
            {
                TmpBOMModel tmp;
                if (layerTmpBom.GetValTmpPart(PrtGUID))
                {
                    var exceptionMessage = "Part already exist you want to add part?";
                    // clsWin.ClearWindowsObJect(panelEx1);
                    //clsWin.ErrorMessage((exceptionMessage).ToString(), "Oops");
                    if (clsWin.QuestionMessage(exceptionMessage, "confirm"))
                    {
                        IList<TmpBOMModel> tmpBom = layerTmpBom.GetAllValTemp(PrtGUID);
                        string tmpGUID = tmpBom[0].tmpGUID.ToString();
                        string prtGUID = tmpBom[0].prtGUID.ToString();
                        double Prt_Qty = double.Parse(tmpBom[0].Prt_Qty.ToString());
                        double Discountedt = double.Parse(tmpBom[0].Prt_Disc.ToString());
                        double prjPrtAmount = double.Parse(tmpBom[0].prjPrtAmount.ToString());
                        Prt_Qty = Prt_Qty + double.Parse(txt_bom_qty.Text);
                        Discountedt = Discountedt +Discount;
                        prjPrtAmount = prjPrtAmount + amount;
                        Discount = Discountedt;

                        tmp = new TmpBOMModel()
                        {
                            tmpGUID = Guid.NewGuid().ToString(),
                            prtGUID = PrtGUID,
                            Prt_Qty = double.Parse(txt_bom_qty.Text),
                            Prt_Disc = Discount,
                            prjPrtAmount = prjPrtAmount - Discount
                        };
                        layerTmpBom.UpdatetQtyTemp(PrtGUID, Prt_Qty, Discount, prjPrtAmount);
                        clsWin.SuccessMessage("Part has been saved", "Success");
                        //Btn_refresh.PerformClick();
                        getListData();
                        clsWin.ClearWindowsObJect(groupBox2);
                        return;
                    }
                    else { clsWin.ClearWindowsObJect(groupBox2); return; }

                }

                tmp = new TmpBOMModel()
                {
                    tmpGUID = Guid.NewGuid().ToString(),
                    prtGUID = PrtGUID,
                    prjPrtOrigCurGUID = CryGUID,
                    prjPrtOrigPrice = OrigPrice,
                    prjPrtPrice = double.Parse(conversionvalue.ToString()),
                    Prt_Qty = double.Parse(txt_bom_qty.Text.ToString()),
                    Prt_Disc = Discount

                };
                layerTmpBom.InSertTemp(tmp);

                clsWin.SuccessMessage("Part has been saved", "Success");
               // Btn_refresh.PerformClick();

                getListData();

            }

            clsWin.ClearWindowsObJect(groupBox2);
        }
Esempio n. 2
0
        public bool InSertTemp(TmpBOMModel model)
        {
            try
            {
                ExecuteCommand(cn =>
                {
                    MySqlCommand cmd = new MySqlCommand(@"Insert Into tbltmpbom
                    (tmpGUID,prtGUID  ,prjPrtOrigCurGUID,prjPrtOrigPrice ,prjPrtPrice ,Prt_Qty,Prt_Disc,prjPrtAmount )
             values(@tmpGUID,@prtGUID,@prjPrtOrigCurGUID,@prjPrtOrigPrice,@prjPrtPrice,@Prt_Qty,@Prt_Disc,@prjPrtAmount)", cn);
                    cmd.Parameters.AddWithValue("@tmpGUID", model.tmpGUID);
                    cmd.Parameters.AddWithValue("@prtGUID", model.prtGUID);
                    cmd.Parameters.AddWithValue("@prjPrtOrigCurGUID", model.prjPrtOrigCurGUID);
                    cmd.Parameters.AddWithValue("@prjPrtOrigPrice", model.prjPrtOrigPrice);
                   // cmd.Parameters.AddWithValue("@prjPrtCurGUID", model.prjPrtCurGUID);
                    cmd.Parameters.AddWithValue("@prjPrtPrice", model.prjPrtPrice);
                    cmd.Parameters.AddWithValue("@Prt_Qty", model.Prt_Qty);
                    cmd.Parameters.AddWithValue("@Prt_Disc", model.Prt_Disc);
                    cmd.Parameters.AddWithValue("@prjPrtAmount", model.prjPrtAmount);
                    rst = cmd.ExecuteNonQuery();

                });
                if (rst == 1)
                    return true;
                else
                    return false;

            }
            catch (Exception)
            {

                throw;
            }
        }